package com.lark.wifi.util;

import android.util.Log;

import com.mtk.launcher.config.AppConfig;
import com.mtk.launcher.util.FileUtil;
import com.mtk.launcher.util.SimpleDateUtil;

import java.io.File;

public class MyLog {
    public static void e(String tag, String s) {
        Log.e(tag, s);
    }

    public static void d(String tag, String s) {
        Log.d(tag, "mirror=" + s);
    }

    public static void test(String s) {
        e("testLog", s);
        printExceptionToSd("testLog", s);
    }

    public static void wifi(String desc) {
        d("wifiLog", desc);
    }

    public static void cdl(String s) {
        e("LauncherLog", s);
        printExceptionToSd("LauncherLog", s);
    }

    public static void powerOnOff(String s) {
        e("powerOnOffLog", s);
        printExceptionToSd("powerOnOffLog", s);
    }

    public static void permission(String s) {
        Log.e("permissionLog", s);
    }

    private static void printExceptionToSd(String printTag, String message) {
        if (!AppConfig.PERMISSION_COMPLAIY) {
            return;
        }
        try {
            String dataInfo = SimpleDateUtil.getCurrentDateLong() + ".txt";
            String woekPlace = AppConfig.LOG_PATH + "/" + dataInfo;
            File file = new File(woekPlace);
            if (file.exists() && file.isDirectory()) {
                file.delete();
            }
            if (!file.exists()) {
                file.createNewFile();
            }
            long currentTime = SimpleDateUtil.getCurrentTimelONG();
            FileUtil.writeMessageInfoToTxt(woekPlace, currentTime + "=" + printTag + " = " + message);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
